﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Threading;
using JasLib.Extensions;
using JasLib.Threading;
using JasLib.Wpf;

namespace WpfFizzBuzz.ViewModels
{
    /*****************************************************************************************************/
    public class FactorInfo : ICloneable
    {
        public FactorViewModel _parentViewModel = null;
        public string _strName = null;
        public int _iFactor = 1;

        public FactorInfo(FactorViewModel parentViewModel, string strName, int iFactor)
        {
            _parentViewModel = parentViewModel;
            _strName = strName;
            _iFactor = iFactor;
            return;
        }

        public object Clone()
        {
            return new FactorInfo(_parentViewModel, _strName, _iFactor);
        }
    }

    /*****************************************************************************************************/
    public class FactorViewModel : ViewModelBase<FactorViewModel>
    {
        private MainViewModel _parentViewModel = null;
        private FactorInfo _factor = null;

        public string Name
        {
            get { return _factor._strName; }
            set { SetProperty(ref _factor._strName, value, () => Name); }
        }

        public int Factor
        {
            get { return _factor._iFactor; }
            set { SetProperty(ref _factor._iFactor, value, () => Factor); }
        }

        private int _iMatchCount = 0;
        public int MatchCount
        {
            get { return _iMatchCount; }
            internal set { SetProperty(ref _iMatchCount, value, () => MatchCount); }
        }

        public FactorViewModel(MainViewModel parentViewModel, string strName, int iFactor)
        {
            _parentViewModel = parentViewModel;
            _factor = new FactorInfo(this, strName, iFactor);
            return;
        }
    }
}
